/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model.staff;

import model.Constants;
import model.personInfo.Contacts;
import model.personInfo.Name;
import model.personInfo.Origin;

/**
 * Represents teacher in university.
 * @author Dmitri Paziy
 */
public class Teacher extends Person{
    private int salary;
    private Degree degree;

    public Teacher(Name name, Origin origin, Contacts contacts) {
        super(name, origin, contacts);
        salary = Constants.MINIMAL_SALARY;
        degree = Degree.Doctor;
    }

    /**
     * Getter of salary. Default value: 
     * Constants.MINIMAL_SALARY = {@value Constants#MINIMAL_SALARY}
     * @return Teacher's salary
     * @see Constants#MINIMAL_SALARY
     */
    public int getSalary() {
        return salary;
    }

    /**
     * Setter of teacher's salary, must be greater than minimal salary 
     * (Constants.MINIMAL_SALARY = {@value Constants#MINIMAL_SALARY}).
     * @param salary Salary of teacher
     * @throws IllegalArgumentException if specified value is incorrect.
     * @see Constants#MINIMAL_SALARY
     */
    public void setSalary(int salary) {
        if (salary < Constants.MINIMAL_SALARY) {
            throw new IllegalArgumentException("Value must be greater than " 
                    + Constants.MINIMAL_SALARY);
        }
        
        this.salary = salary;
    }

    /**
     * Getter of teachers degree, by default degree = {@link Degree#Doctor}
     * @return Degree
     * @see Degree
     */
    public Degree getDegree() {
        return degree;
    }

    /**
     * Setter of teachers degree.
     * @param degree New degree of teacher.
     * @throws IllegalArgumentException if specified degree is <i>null</i>.
     */
    public void setDegree(Degree degree) {
        if (degree == null) {
            throw new IllegalArgumentException(Constants.NULL_ARGUMENT_MESSAGE);
        }
        
        this.degree = degree;
    }
    
    /**
     * Changes salary of teacher. May be used to either increase or decrease salary.
     * @param value Value to add to salary.
     * @return New value of salary.
     */
    public int changeSalary(int value) {
        return salary += value;
    }
}
